<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.util.Set"%>
<%@page import="cn.edu.zjut.chopper.message.RemoteInterface"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script language ="javascript" src ="/chopper/js/jquery-1.5.2.js"></script > 
<title>Chopper Registry</title>
</head>
<body style="background-color: #AFEEEE; text-align: center;">
<jsp:include page="head.html"/>
<% 
	Map<String, Set<RemoteInterface>> serverRemoteInterfaces = (Map<String, Set<RemoteInterface>>)request.getAttribute("serverRemoteInterfaces"); 
%>
<center>
<table width="800" style="text-align: center;">
	<tr>
		<td colspan="2"><div style="font-size:20pt;">Remote Interface list</div> <img width="20" height="20" src="/chopper/image/refresh.png"><a href="/chopper/RemoteInterfaceServerView">refresh</a></td>
	</tr>
	<tr style="background-color: #969696">
		<td width="60%">Server IP</td>
		<td width="40%">Instance Count</td>
	</tr>
	<%
		int i=0;
		for (Entry<String, Set<RemoteInterface>> m : serverRemoteInterfaces.entrySet()) {
			i++;
			out.println("<tr id=\"riSet"+i+"\" style=\"background-color:#90EE90;cursor:hand;\" onclick=\"if($('#riContent"+i+"').css('display')=='none'){$('#riContent"+i+"').slideDown('slow');}else{$('#riContent"+i+"').slideUp('slow');}\"><td>"+m.getKey()+"</td><td>"+((Set)m.getValue()).size()+"</td></tr>");
			out.println("<tr><td colspan=\"2\"><div id=\"riContent"+i+"\" style=\"display:none;\"><table width=\"100%\">");
			out.println("<tr style=\"background-color: #969696;\"><td width=\"10%\">Name</td><td width=\"10%\">Version</td><td width=\"40%\">Url</td><td width=\"10%\">Count</td><td width=\"10%\">Run</td><td width=\"10%\">Moniter</td><td width=\"10%\">Remove</td></tr>");
			for(RemoteInterface ri : m.getValue()){
	    		out.println("<tr id=\"riContent\" style=\"background-color: #FFFF99;\"><td width=\"20%\">"+ri.getName()+"</td><td width=\"20%\">"+ri.getVersion()+"</td><td width=\"40%\">"+ri.getUrl()+"</td><td width=\"10%\">"+ri.getCount()+"</td><td width=\"10%\"><a href=\"/chopper/TestInterface?action=show_method&Name="+ri.getName()+"&Url="+ri.getUrl()+"&Version="+ri.getVersion()+"\"><img width=\"15\" height=\"15\" src=\"/chopper/image/run.png\"></a></td><td width=\"10%\"><a href=\"/chopper/RemoteInterfaceMonitorView?Name="+ri.getName()+"&Url="+ri.getUrl()+"&Version="+ri.getVersion()+"\"><img width=\"15\" height=\"15\" src=\"/chopper/image/moniter.png\"></a></td><td width=\"10%\"><a href=\"/chopper/DeleteRemoteInterface?Name="+ri.getName()+"&Url="+ri.getUrl()+"&Version="+ri.getVersion()+"\"><img width=\"15\" height=\"15\" src=\"/chopper/image/remove.png\"></a></td></tr>");
	    	}
			out.println("</table></div></td></tr>");
	    }
		%>
</table>
</center>
<jsp:include page="foot.html"/>
</body>
</html>